package com.yyh.io2;

import java.io.*;

/*3.分别使用文件流和缓冲流复制一个长度大于100MB的视频文件，并观察效率的差异。*/
public class Test33 {
    public static void main(String[] args) throws IOException {
        //获取时间
        long start = System.currentTimeMillis();
        //创建字节缓冲流对象
        FileInputStream fis = new FileInputStream("D:\\course\\02-JavaSE进阶\\day10-IO流\\录屏\\108-打印流.avi");
        BufferedInputStream bis = new BufferedInputStream(fis);
        FileOutputStream fos = new FileOutputStream("D:\\course\\02-JavaSE进阶\\day10-IO流\\aa.avi");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        //打开水龙头，开始读，写
        byte[] bytes = new byte[1024];
        int len;
        while ((len = fis.read(bytes)) != -1) {
            fos.write(bytes, 0, len);
            bos.flush();
        }
        //关闭管道
        bos.close();
        bis.close();
        //获取时间
        long end = System.currentTimeMillis();
        System.out.println("复制完毕，耗时：" + (end - start) + "毫秒");
        System.out.println("-------------------------------");
        //创建文件流对象
        long start1 = System.currentTimeMillis();
        //创建文件流对象
        FileInputStream fis1 = new FileInputStream("D:\\course\\02-JavaSE进阶\\day10-IO流\\录屏\\108-打印流.avi");
        FileOutputStream fos1 = new FileOutputStream("D:\\course\\02-JavaSE进阶\\day10-IO流\\aa.avi");
        //打开水龙头，开始读，写
        byte[] bytes1 = new byte[1024];
        int len1;
        while ((len1 = fis1.read(bytes1)) != -1) {
            fos1.write(bytes1, 0, len1);
        }
        //关闭管道
        fos1.close();
        fis1.close();
        long end1 = System.currentTimeMillis();
        System.out.println("复制完毕，耗时：" + (end1 - start1) + "毫秒");

    }
}
